<html>
<head><meta charset="utf-8"><title>Cargo makes no effort to deduplicate with lax depbounds? · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html">Cargo makes no effort to deduplicate with lax depbounds?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227615600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227615600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227615600">(Feb 24 2021 at 15:29)</a>:</h4>
<p>So I have a cargo toml like this:</p>
<div class="codehilite"><pre><span></span><code>[dependencies]
ndarray = &quot;&gt;= 0.13, &lt; 0.15&quot;
other_crate = &quot;1.2.3&quot; # depends on ndarray = ^0.13
</code></pre></div>
<p>Now that ndarray has released 0.14, cargo is duplicating the ndarray dependency rather than just using 0.13. Is this the intended behaviour?</p>



<a name="227616171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227616171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227616171">(Feb 24 2021 at 15:32)</a>:</h4>
<p>Minimizing duplicate dependencies is NP-hard, though I think heuristics in cargo have slowly been improving</p>



<a name="227616823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227616823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227616823">(Feb 24 2021 at 15:36)</a>:</h4>
<p>Personally I would much rather have <code>cargo update</code> take longer to run than have more dependencies</p>



<a name="227617104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227617104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227617104">(Feb 24 2021 at 15:38)</a>:</h4>
<p>sure, but unless you're willing to wait an exponentially longer amount of time as your dependency graph grows, doing that requires something akin to a high performance SAT solver or nonlinear optimizer which is a pretty complex beast</p>



<a name="227617724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227617724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227617724">(Feb 24 2021 at 15:41)</a>:</h4>
<p>Currently Cargo makes very little effort to minimize the number of dependencies like this. When there are multiple solutions to a resolution graph (such as picking 0.13 or picking both 0.13 and 0.14 here) Cargo doesn't provide great knobs to control which solution gets picked. Cargo also has no automatic guidance of which solution to pick. Long ago the idea of public/private dependencies were thought to be a way to force Cargo to "unify" versions here since it would be a hard constraint on the version resolution solution.</p>



<a name="227618137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227618137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227618137">(Feb 24 2021 at 15:43)</a>:</h4>
<p>See also <a href="https://github.com/rust-lang/cargo/issues/9029#issuecomment-752801333">https://github.com/rust-lang/cargo/issues/9029#issuecomment-752801333</a></p>



<a name="227619380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20makes%20no%20effort%20to%20deduplicate%20with%20lax%20depbounds%3F/near/227619380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20makes.20no.20effort.20to.20deduplicate.20with.20lax.20depbounds.3F.html#227619380">(Feb 24 2021 at 15:50)</a>:</h4>
<p>Thanks Eric, I was just going to try to find that comment. That comment still encapsulates my thoughts.<br>
Pubgrub is making progress, and will make adding knobs more doable. (but know promesses especially about timeline.)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>